
N.optimization2 = N.Class.extend({
    resize: function () {
        // var topheight = $(".container-fluid").height() - $(".content-header").height() - 5;
        var topheight = $('.container-fluid').height() - 20
        var bottomheight = topheight * (1 / 2)
        var boxtop = bottomheight - 120
        var maptop = topheight * (2 / 3) - 60
        var mapbot = topheight * (1 / 3) - 60
        $('.control-size-box').height(boxtop)
        $('.control-size-box-map').height(maptop)
        $('.control-size-box-mapbot').height(mapbot)

        var headheight = $('#table1_wrapper .dataTables_scrollHeadInner').height()
        if (headheight) {
            this.tablbeHeight = boxtop - headheight - 5
            $('#table1_wrapper .dataTables_scrollBody').height(this.tablbeHeight)
        }
        headheight = $('#table2_wrapper .dataTables_scrollHeadInner').height()
        if (headheight) {
            this.tablbeHeight = boxtop - headheight - 5
            $('#table2_wrapper .dataTables_scrollBody').height(this.tablbeHeight)
        }
    },
    pageLoad: function (geography, shiduan, geo_dim, city, area) {
        loading.show()
        if (geography) {
            this.geographyChart(shiduan, geo_dim, city, area)
        } else {
            this.timeChart(shiduan, geo_dim, city, area)
        }
        this.chartTop(shiduan, geo_dim, city, area)
    },
    chartTop: function (shiduan, geo_dim, city, area) {
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                area: area
            }
        } else {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                city: city,
                area: area
            }
        }
        $.ajax({
            url: getApiPath() + 'wideTable/geographyChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                try {
                    $('#com_worksheet_qualified_rate').text(result[0].com_worksheet_qualified_rate)// 集中投诉工单合格率
                    $('#analysis_work_order_solved_rate').text(result[0].analysis_work_order_solved_rate)// 集中分析优化工单解决
                    $('#high_lr_ul_num_volte').text(result[0].high_lr_ul_num_volte)// VOLTE上行高丢包小区数
                    $('#high_lr_ul_rate_volte').text(result[0].high_lr_ul_rate_volte)// VOLTE上行高丢包小区占比
                    $('#high_load_num_volte').text(result[0].high_load_num_volte)// VOLTE高负荷小区数
                    $('#high_load_rate_volte').text(result[0].high_load_rate_volte)// VOLTE高负荷小区占比
                    $('#suc_conn_estab_nb').text(result[0].suc_conn_estab_nb)// 连接成功次数
                    $('#att_conn_estab_nb').text(result[0].att_conn_estab_nb)// 连接请求次数
                    $('#rrc_succ_rate_nb').text(result[0].rrc_succ_rate_nb)// 连接成率
                    $('#high_lr_dl_num_volte').text(result[0].high_lr_dl_num_volte)// VOLTE下行高丢包小区数
                    $('#high_lr_dl_rate_volte').text(result[0].high_lr_dl_rate_volte)// VOLTE下行高丢包小区占比
                } catch (e) {
                    console.log(e)
                }
                loading.hide()
            }
        })
    },
    geographyChart: function (shiduan, geo_dim, city, area) {
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: '地市',
                time_dim: shiduan,
                area: area
            }
        } else if (geo_dim === '地市' || geo_dim === '区县') {
            param = {
                geo_dim: '区县',
                time_dim: shiduan,
                city: city
            }
        }

        $.ajax({
            url: getApiPath() + 'wideTable/geographyChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                // 横坐标
                var xArr = []
                // 纵坐标
                var com_worksheet_qualified_rate = [], analysis_work_order_solved_rate = [], high_lr_ul_num_volte = [], high_lr_ul_rate_volte = [], high_load_num_volte = [], high_load_rate_volte = [], suc_conn_estab_nb = [], att_conn_estab_nb = [], rrc_succ_rate_nb = [], high_lr_dl_num_volte = [], high_lr_dl_rate_volte = []
                $.each(result, function (index, value) {
                    if (value.area === '全量小区') {
                        xArr.push(value.city)
                    } else {
                        xArr.push(value.area)
                    }
                    com_worksheet_qualified_rate.push(value.com_worksheet_qualified_rate)
                    analysis_work_order_solved_rate.push(value.analysis_work_order_solved_rate)
                    high_lr_ul_num_volte.push(value.high_lr_ul_num_volte)
                    high_lr_ul_rate_volte.push(value.high_lr_ul_rate_volte)
                    high_load_num_volte.push(value.high_load_num_volte)
                    high_load_rate_volte.push(value.high_load_rate_volte)
                    suc_conn_estab_nb.push(value.suc_conn_estab_nb)
                    att_conn_estab_nb.push(value.att_conn_estab_nb)
                    rrc_succ_rate_nb.push(value.rrc_succ_rate_nb)
                    high_lr_dl_num_volte.push(value.high_lr_dl_num_volte)
                    high_lr_dl_rate_volte.push(value.high_lr_dl_rate_volte)
                })

                // 工单合格率、解决率
                drawColumnCol({
                    id: 'line1',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '集中投诉工单合格率(%)',
                            type: 'line',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: com_worksheet_qualified_rate,
                            yAxis: 0,
                            axisLabelY: '%'
                        }, {
                            name: '集中分析优化工单解决率(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: analysis_work_order_solved_rate,
                            yAxis: 1,
                            axisLabelY: '%'
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 250,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    lenabledWidth: 10,
                    layout: 'horizontal'
                })

                // VoLTE上行高丢包
                drawColumnCol({
                    id: 'line2',
                    title: null,
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    chart: {
                        zoomType: 'x',
                        panning: true,
                        panKey: 'shift',
                        maxPointWidth: 15
                    },
                    data: [
                        {
                            name: 'VoLTE上行高丢包小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_lr_ul_num_volte,
                            yAxis: 0
                        }, {
                            name: 'VoLTE上行高丢包小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_lr_ul_rate_volte,
                            // dashStyle: 'shortdot',
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    lenabledWidth: 10,
                    layout: 'horizontal'
                })

                // VOLTE高负荷小区
                drawColumnCol({
                    id: 'line4',
                    title: 'VOLTE高负荷小区',
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    data: [
                        {
                            name: 'VOLTE高负荷小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_load_num_volte,
                            yAxis: 0
                        }, {
                            name: 'VOLTE高负荷小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_load_rate_volte,
                            yAxis: 1
                        }
                    ],

                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    layout: 'horizontal',
                    height: 165
                })

                // NB-IOT RRC连接成功率
                drawColumnCol({
                    id: 'line5',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '连接成功次数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: suc_conn_estab_nb,
                            yAxis: 0
                        }, {
                            name: '连接请求次数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.red,
                            data: att_conn_estab_nb
                        }, {
                            name: '连接成率(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: rrc_succ_rate_nb,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    layout: 'horizontal'
                })

                // VoLTE下行高丢包
                drawColumnCol({
                    id: 'line6',
                    title: 'VoLTE下行高丢包\n',
                    cate: xArr,
                    data: [
                        {
                            name: 'VOLTE下行高丢包小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_lr_dl_num_volte,
                            yAxis: 0
                        }, {
                            name: 'VOLTE下行高丢包小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_lr_dl_rate_volte,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    layout: 'horizontal'
                })
                loading.hide()
            }
        })
    },
    timeChart: function (shiduan, geo_dim, city, area) {
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                area: area,
                num: shiduan == 'M' ? 6 : 7
            }
        } else {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                city: city,
                area: area,
                num: shiduan == 'M' ? 6 : 7
            }
        }
        $.ajax({
            url: getApiPath() + 'wideTable/timeChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                // 横坐标
                var xArr = []
                // 纵坐标
                var com_worksheet_qualified_rate = [], analysis_work_order_solved_rate = [], high_lr_ul_num_volte = [], high_lr_ul_rate_volte = [], high_load_num_volte = [], high_load_rate_volte = [], suc_conn_estab_nb = [], att_conn_estab_nb = [], rrc_succ_rate_nb = [], high_lr_dl_num_volte = [], high_lr_dl_rate_volte = []
                for (var i = result.length - 1; i > -1; i--) {
                    // $.each(result,function (index, value) {
                    var value = result[i]
                    xArr.push(value.starttime.substr(5, 5))
                    com_worksheet_qualified_rate.push(value.com_worksheet_qualified_rate)
                    analysis_work_order_solved_rate.push(value.analysis_work_order_solved_rate)
                    high_lr_ul_num_volte.push(value.high_lr_ul_num_volte)
                    high_lr_ul_rate_volte.push(value.high_lr_ul_rate_volte)
                    high_load_num_volte.push(value.high_load_num_volte)
                    high_load_rate_volte.push(value.high_load_rate_volte)
                    suc_conn_estab_nb.push(value.suc_conn_estab_nb)
                    att_conn_estab_nb.push(value.att_conn_estab_nb)
                    rrc_succ_rate_nb.push(value.rrc_succ_rate_nb)
                    high_lr_dl_num_volte.push(value.high_lr_dl_num_volte)
                    high_lr_dl_rate_volte.push(value.high_lr_dl_rate_volte)
                    // });
                }
                // 工单合格率、解决率
                drawColumnCol({
                    id: 'line1',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '集中投诉工单合格率(%)',
                            type: 'line',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: com_worksheet_qualified_rate,
                            yAxis: 0,
                            axisLabelY: '%'
                        }, {
                            name: '集中分析优化工单解决率(%)\n',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: analysis_work_order_solved_rate,
                            yAxis: 0,
                            axisLabelY: '%'
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 250,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    lenabledWidth: 10,
                    layout: 'horizontal'
                })

                // VoLTE上行高丢包
                drawColumnCol({
                    id: 'line2',
                    title: null,
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    chart: {
                        zoomType: 'x',
                        panning: true,
                        panKey: 'shift',
                        maxPointWidth: 15
                    },
                    data: [
                        {
                            name: 'VoLTE上行高丢包小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_lr_ul_num_volte,
                            yAxis: 0
                        }, {
                            name: 'VoLTE上行高丢包小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_lr_ul_rate_volte,
                            // dashStyle: 'shortdot',
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    lenabledWidth: 10,
                    layout: 'horizontal'
                })

                // VOLTE高负荷小区
                drawColumnCol({
                    id: 'line4',
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    data: [
                        {
                            name: 'VOLTE高负荷小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_load_num_volte,
                            yAxis: 0
                        }, {
                            name: 'VOLTE高负荷小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_load_rate_volte,
                            yAxis: 1
                        }
                    ],

                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    layout: 'horizontal',
                    height: 165
                })

                // NB-IOT RRC连接成功率
                drawColumnCol({
                    id: 'line5',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '连接成功次数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: suc_conn_estab_nb,
                            yAxis: 0
                        }, {
                            name: '连接请求次数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.red,
                            data: att_conn_estab_nb
                        }, {
                            name: '连接成率(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: rrc_succ_rate_nb,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    layout: 'horizontal'
                })

                // VoLTE下行高丢包
                drawColumnCol({
                    id: 'line6',
                    title: 'VoLTE下行高丢包\n',
                    cate: xArr,
                    data: [
                        {
                            name: 'VOLTE下行高丢包小区数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: high_lr_dl_num_volte,
                            yAxis: 0
                        }, {
                            name: 'VOLTE下行高丢包小区占比(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: high_lr_dl_rate_volte,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'bottom',
                    layout: 'horizontal'
                })
                loading.hide()
            }
        })
    }
})
var page = new N.optimization2()

$(function () {
    $(document).on('map:click', function (event, geography, shiduan, geo_dim, map_city, map_area) {
        page.pageLoad(geography, shiduan, geo_dim, map_city, map_area)
    })
})



